package com.buddy.summary.code.utils;

import org.dom4j.Document;
import org.dom4j.io.XMLWriter;

import java.io.FileWriter;
import java.io.IOException;

public class WriteXmlUtil {
    /**
     * 将文档对象写入对应的文件中
     * @param document      文档对象
     * @param path          写入文档的路径
     * @throws IOException
     */
    public static void writeXMLToFile(Document document, String path) throws IOException {
        if(document==null||path==null){
            return;
        }
        XMLWriter writer = new XMLWriter(new FileWriter(path));
        writer.write(document);
        writer.close();
    }
}
